﻿<!--
    Copyright (C) 2011 Ari Rokosa, Chinedu Eze, Johannes Virtanen,
                       Petri Tuononen, Timo Korkalainen

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
@{Layout=null;} 

<div id="topics-up-button" class="button-small"></div>
<div id="topics-down-button" class="button-small"></div>

<script type="text/javascript">

    function topics_toggle() { $('#topics-up-button').toggle(); $('#topics-down-button').toggle()}

    $('#topics-up-button').click(function () {
        topics_toggle();
        $('#topics-container').animate({ "top": "40%" }, 'fast');
    });

    $('#topics-down-button').click(function () {
        topics_toggle();
        $('#topics-container').animate({ "top": "75%" }, 'fast');
    });
</script>

<script type="text/javascript">
    function refreshTopics() {
            $.post("Topics/RenderTopicsHttpPost", function (data) {
                $('#topic-list').html(data);
            });
        }

    var refreshId = setInterval("refreshTopics()", 6000);
    
    $(document).ready(refreshTopics());

    function clearTopicInput() {
        $('#topic-input').val("");
    }
</script>

@using (Ajax.BeginForm("AddTopic", "Topics", new AjaxOptions {UpdateTargetId="topic-list", InsertionMode=InsertionMode.Replace, HttpMethod="post", OnBegin="clearTopicInput" }))
{
    <div id="new-topic-container">
        <input id="topic-submit" class="button-small" type="submit" value="" maxlength="160"/>
        @Html.TextBox("content", "", new { id = "topic-input" })
    </div>
}

<div id="topic-list">
</div>